#include <stdio.h>
#include <string.h>

int n, a, b;

int main() {
	printf("Please enter the first term of the sequence.\n");
	scanf("%d", &a);
	printf("Please enter the second term of the sequence.\n");
	scanf("%d", &b);
	printf("Please enter the numbers of terms you want to output.\n");
	scanf("%d", &n);
	printf("The sequence is : \n");
	for(int i = 1; i <= n; i++) {
		printf("%d%c", a, " \n"[i == n]);
		b = a + b, a = b - a;
	} 
	return 0;	
}

/*
上面代码更能体现迭代的思想，但是可读性极差，大部分情况下还是要保存数列的信息的
所以最好还是用数组：
const int maxn = 1e6 + 17;
int n, f[maxn];

int main() {
	printf("Please enter the first term of the sequence.\n");
	scanf("%d", &f[1]);
	printf("Please enter the second term of the sequence.\n");
	scanf("%d", &f[2]);
	printf("Please enter the numbers of terms you want to output.\n");
	scanf("%d", &n);
	printf("The sequence is : \n");
	for(int i = 1; i <= n; i++) {
		if(i > 2) f[i] = f[i - 1] + f[i - 2];
		printf("%d%c", f[i], " \n"[i == n]);
	} 
	return 0;
}
*/